const baseUrl = 'https://music.0melon0.cn';

async function _fetch(_url, _data='') {
  let requestUrl = baseUrl + _url;
  if (_data) {
    requestUrl +='?'
    for (const k in _data) {
      requestUrl += `${k}=${_data[k]}&`;
    }
  requestUrl=requestUrl.slice(0,-1)
   
  }
  let fetchRes = await fetch(requestUrl, {
    method: 'GET',
  });
  let fetchData = await fetchRes.json();

  return fetchData
}

module.exports = _fetch;
